package com.bupt.uchouten.common.logic;

import com.pixelmonmod.pixelmon.api.pokemon.Element;
import com.pixelmonmod.pixelmon.api.pokemon.Pokemon;
import com.pixelmonmod.pixelmon.api.pokemon.item.pokeball.PokeBall;
import com.pixelmonmod.pixelmon.api.pokemon.item.pokeball.logic.BallLogic;
import com.pixelmonmod.pixelmon.battles.controller.participants.PixelmonWrapper;
import com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallEntity;
import com.pixelmonmod.pixelmon.entities.pokeballs.PokeBallMode;
import net.minecraft.world.entity.player.Player;

import javax.annotation.Nullable;
import java.util.Optional;

/**
 * @author wujichen158
 */
public class TenkaiBall implements BallLogic {

    public TenkaiBall() {
    }

    @Override
    public double getCatchBonus(PokeBall type, @Nullable PokeBallEntity entity, Player thrower, Pokemon pokemon, PokeBallMode mode) {
        Optional<PixelmonWrapper> pw = pokemon.getPixelmonWrapper();
        return !pokemon.getForm().hasType(Element.FLYING, Element.GROUND) && (pw.isEmpty() || !pw.get().hasType(Element.FLYING, Element.GROUND)) ? 1.0 : type.getCatchBonus();
    }
}
